package com.norbitltd.guavaleaves.java.lang;

import com.google.common.base.Predicate;

public class IntegerPredicates extends ObjectPredicates {
	
	/**
	 * Returns a predicate which checks whether the predicate argument is greater than a given int value
	 * @param i Value to compare the predicate value with
	 * @return True if the predicate value is greater than i, false otherwise
	 */
	public static Predicate<Integer> isGreaterThan(final int i) {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input > i;
			}
		};
	}

	/**
	 * Returns a predicate which checks whether the predicate argument is greater than or equal to a given int value
	 * @param i Value to compare the predicate value with
	 * @return True if the predicate value is greater than or equal to i, false otherwise
	 */
	public static Predicate<Integer> isGreaterOrEqualThan(final int i) {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input >= i;
			}
		};
	}

	/**
	 * Returns a predicate which checks whether the predicate argument is lower than a given int value
	 * @param i Value to compare the predicate value with
	 * @return True if the predicate value is lower than i, false otherwise
	 */
	public static Predicate<Integer> isLowerThan(final int i) {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input < i;
			}
		};
	}

	/**
	 * Returns a predicate which checks whether the predicate argument is lower that or equal to than a given int value
	 * @param i Value to compare the predicate value with
	 * @return True if the predicate value is lower than or equal to i, false otherwise
	 */
	public static Predicate<Integer> isLowerOrEqualThan(final int i) {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input <= i;
			}
		};
	}
	
	/**
	 * Returns a predicate which check whether the predicate argument is equal to a given int value
	 * @param i Value to compare the predicate value with
	 * @return True if the predicate value is equal to i, false otherwise
	 */
	public static Predicate<Integer> isEqual(final int i) {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input == i;
			}
		};
	}
	
	/**
	 * Returns a predicate which check whether the predicate argument is not equal to a given int value
	 * @param i Value to compare the predicate value with
	 * @return True if the predicate value is not equal to i, false otherwise
	 */
	public static Predicate<Integer> isNotEqual(final int i) {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input != i;
			}
		};
	}
	
	/**
	 * Returns a predicate which check whether the predicate argument is a positive int value
	 * @return True if the predicate value is greater than 0, false otherwise
	 */
	public static Predicate<Integer> isPositive() {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input > 0;
			}
		};
	}
	

	/**
	 * Returns a predicate which check whether the predicate argument is a negative int value
	 * @return True if the predicate value is lower than 0, false otherwise
	 */
	public static Predicate<Integer> isNegative() {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input < 0;
			}
		};
	}
	
	/**
	 * Returns a predicate which check whether the predicate argument is a zero-valued int value
	 * @return True if the predicate value is equal 0, false otherwise
	 */
	public static Predicate<Integer> isZero() {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input == 0;
			}
		};
	}
	
	/**
	 * Returns a predicate which check whether the predicate argument is not a zero-valued int value
	 * @return True if the predicate value is not equal 0, false otherwise
	 */
	public static Predicate<Integer> isNotZero() {
		return new Predicate<Integer>() {
			public boolean apply(Integer input) {
				return input != null && input != 0;
			}
		};
	}
}